<template>
  <div>
    <common-head title="编辑联系人"></common-head>
    <div class="wrap">
      <van-address-edit
        :area-list="$store.state.areaList"
        :address-info= "contacts[parseInt($route.params.index)]"
        show-postal
        show-set-default
        :area-columns-placeholder="['请选择', '请选择', '请选择']"
        @save="onSave"
      />
    </div>
  </div>
</template>

<script>
import CommonHead from 'components/CommonHead'
import { mapMutations, mapState } from 'vuex'
import { Toast } from 'vant'
export default {
  methods: {
    onSave (content) {
      this.editContact({
        contact: content,
        index: parseInt(this.$route.params.index)
      })
      Toast('更新成功')
    },
    ...mapMutations('contact', ['editContact'])
  },
  computed: {
    ...mapState({
      contacts: state => state.contact.contacts
    })
  },
  components: {
    CommonHead
  }
}
</script>

<style lang="scss" scoped>

</style>